package com.hl.controller;

import com.hl.domain.Consultreply;
import com.hl.mapper.ConsultreplyMapper;
import com.hl.service.ConsultreplyService;
import com.hl.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/reply")
public class ConsultreplyController {
    @Autowired
    private ConsultreplyService consultreplyService;

    //返回回复楼
    @GetMapping
    public R find(Long problemId){
        List<Consultreply> reply = consultreplyService.reply(problemId);
        return reply!=null?R.success(reply):R.fail(null);
    }

    //插入发表回复
    @PostMapping
    public R add(@RequestBody Consultreply consultreply){
        int addreply = consultreplyService.addreply(consultreply);
        return addreply>0?R.success(addreply):R.fail(0);
    }

    //回复
    @PostMapping("/addReply")
    //新增
    public R insertSelective(Consultreply record){
        int row = consultreplyService.insertSelective(record);
        return row>0 ? R.success(row) :R.fail(row);
    }
}
